package pers.cz.chat.factory;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import org.jetbrains.annotations.NotNull;
import pers.cz.chat.ui.ChatUi;

/**
 * @version 1.0
 * @description:
 * @author: ChengZhi 0336
 * @create: 2025-01-24 16:59
 **/
public class ChatFactory implements ToolWindowFactory {

	private ChatUi chatUi = new ChatUi();

	@Override
	public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
		// 获取内容工厂的实例
		ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
		// 获取 ToolWindow 显示的内容
		Content content = contentFactory.createContent(chatUi.getComponent(), "", false);
		// 设置 ToolWindow 显示的内容
		toolWindow.getContentManager().addContent(content);
		// 全局使用
		Config.chatUi = chatUi;
	}
}
